package net.borderwars.map;

import java.awt.geom.Point2D;

/**
 * @author Eric
 *         Date: Nov 25, 2003
 *         Time: 10:28:13 PM
 */
public class Point extends Point2D {
// ------------------------------ FIELDS ------------------------------

    public int x, y;

// --------------------------- CONSTRUCTORS ---------------------------

    // Create a point from another Point object

    Point (final Point oldPoint) {
        x = oldPoint.x;    // Copy x coordinate
        y = oldPoint.y;    // Copy y coordinate
    }

    Point (double x, double y) {
        this.x = (int) x;
        this.y = (int) y;
    }

    public Point (int x, int y) {
        this.x = x;
        this.y = y;
    }

// ------------------------ CANONICAL METHODS ------------------------

    public String toString () {
        return ("(" + x + "," + y + ")");
    }

// -------------------------- OTHER METHODS --------------------------

    // Calculate the distance to another point

    int distance (final Point aPoint) {
        return (int) Math.sqrt ((x - aPoint.x) * (x - aPoint.x) + (y - aPoint.y) * (y - aPoint.y));
    }

    public double getX () {
        return x;
    }

    public double getY () {
        return y;
    }

    public void setLocation (double x, double y) {
        this.x = (int) x;
        this.y = (int) y;
    }

}
